.class public LPlugclass/updateManager;
.super Ljava/lang/Object;
.source "updateManager.java"


# static fields
.field private static final DOWN_OVER:I = 0x2

.field private static final DOWN_UPDATE:I = 0x1

.field private static final saveFileName:Ljava/lang/String; = "/sdcard/updatedemo/UpdateDemoRelease.apk"

.field private static final savePath:Ljava/lang/String; = "/sdcard/updatedemo/"


# instance fields
.field private apkUrl:Ljava/lang/String;

.field private downLoadThread:Ljava/lang/Thread;

.field private downloadDialog:Landroid/app/Dialog;

.field private interceptFlag:Z

.field private localVersion:I

.field private mContext:Landroid/content/Context;

.field private mHandler:Landroid/os/Handler;

.field private mProgress:Landroid/widget/ProgressBar;

.field private mdownApkRunnable:Ljava/lang/Runnable;

.field private noticeDialog:Landroid/app/Dialog;

.field private progress:I

.field private updateMsg:Ljava/lang/String;


# direct methods
.method public constructor <init>(Landroid/content/Context;I)V
    .locals 2
    .param p1, "context"    # Landroid/content/Context;
    .param p2, "localVersion"    # I

    .prologue
    const/4 v1, 0x0

    .line 94
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 47
    const-string v0, "apk\u5185\u5bb9\u6709\u66f4\u65b0\u53ef\u4ee5\u4e0b\u8f7d\u6700\u65b0\u7248\u672c"

    iput-object v0, p0, LPlugclass/updateManager;->updateMsg:Ljava/lang/String;

    .line 50
    const-string v0, ""

    iput-object v0, p0, LPlugclass/updateManager;->apkUrl:Ljava/lang/String;

    .line 72
    iput-boolean v1, p0, LPlugclass/updateManager;->interceptFlag:Z

    .line 73
    iput v1, p0, LPlugclass/updateManager;->localVersion:I

    .line 75
    new-instance v0, LPlugclass/updateManager$1;

    invoke-direct {v0, p0}, LPlugclass/updateManager$1;-><init>(LPlugclass/updateManager;)V

    iput-object v0, p0, LPlugclass/updateManager;->mHandler:Landroid/os/Handler;

    .line 200
    new-instance v0, LPlugclass/updateManager$2;

    invoke-direct {v0, p0}, LPlugclass/updateManager$2;-><init>(LPlugclass/updateManager;)V

    iput-object v0, p0, LPlugclass/updateManager;->mdownApkRunnable:Ljava/lang/Runnable;

    .line 95
    iput-object p1, p0, LPlugclass/updateManager;->mContext:Landroid/content/Context;

    .line 96
    iput p2, p0, LPlugclass/updateManager;->localVersion:I

    .line 97
    return-void
.end method

.method static synthetic access$0(LPlugclass/updateManager;)Landroid/widget/ProgressBar;
    .locals 1

    .prologue
    .line 61
    iget-object v0, p0, LPlugclass/updateManager;->mProgress:Landroid/widget/ProgressBar;

    return-object v0
.end method

.method static synthetic access$1(LPlugclass/updateManager;)I
    .locals 1

    .prologue
    .line 68
    iget v0, p0, LPlugclass/updateManager;->progress:I

    return v0
.end method

.method static synthetic access$10(LPlugclass/updateManager;Ljava/lang/String;)V
    .locals 0

    .prologue
    .line 50
    iput-object p1, p0, LPlugclass/updateManager;->apkUrl:Ljava/lang/String;

    return-void
.end method

.method static synthetic access$11(LPlugclass/updateManager;)V
    .locals 0

    .prologue
    .line 178
    invoke-direct {p0}, LPlugclass/updateManager;->showDownloadDialog()V

    return-void
.end method

.method static synthetic access$12(LPlugclass/updateManager;Z)V
    .locals 0

    .prologue
    .line 72
    iput-boolean p1, p0, LPlugclass/updateManager;->interceptFlag:Z

    return-void
.end method

.method static synthetic access$2(LPlugclass/updateManager;)V
    .locals 0

    .prologue
    .line 260
    invoke-direct {p0}, LPlugclass/updateManager;->installApk()V

    return-void
.end method

.method static synthetic access$3(LPlugclass/updateManager;)V
    .locals 0

    .prologue
    .line 157
    invoke-direct {p0}, LPlugclass/updateManager;->showNoticeDialog()V

    return-void
.end method

.method static synthetic access$4(LPlugclass/updateManager;)Ljava/lang/String;
    .locals 1

    .prologue
    .line 50
    iget-object v0, p0, LPlugclass/updateManager;->apkUrl:Ljava/lang/String;

    return-object v0
.end method

.method static synthetic access$5(LPlugclass/updateManager;I)V
    .locals 0

    .prologue
    .line 68
    iput p1, p0, LPlugclass/updateManager;->progress:I

    return-void
.end method

.method static synthetic access$6(LPlugclass/updateManager;)Landroid/os/Handler;
    .locals 1

    .prologue
    .line 75
    iget-object v0, p0, LPlugclass/updateManager;->mHandler:Landroid/os/Handler;

    return-object v0
.end method

.method static synthetic access$7(LPlugclass/updateManager;)Z
    .locals 1

    .prologue
    .line 72
    iget-boolean v0, p0, LPlugclass/updateManager;->interceptFlag:Z

    return v0
.end method

.method static synthetic access$8(LPlugclass/updateManager;)Landroid/content/Context;
    .locals 1

    .prologue
    .line 44
    iget-object v0, p0, LPlugclass/updateManager;->mContext:Landroid/content/Context;

    return-object v0
.end method

.method static synthetic access$9(LPlugclass/updateManager;)I
    .locals 1

    .prologue
    .line 73
    iget v0, p0, LPlugclass/updateManager;->localVersion:I

    return v0
.end method

.method private downloadApk()V
    .locals 2

    .prologue
    .line 253
    new-instance v0, Ljava/lang/Thread;

    iget-object v1, p0, LPlugclass/updateManager;->mdownApkRunnable:Ljava/lang/Runnable;

    invoke-direct {v0, v1}, Ljava/lang/Thread;-><init>(Ljava/lang/Runnable;)V

    iput-object v0, p0, LPlugclass/updateManager;->downLoadThread:Ljava/lang/Thread;

    .line 254
    iget-object v0, p0, LPlugclass/updateManager;->downLoadThread:Ljava/lang/Thread;

    invoke-virtual {v0}, Ljava/lang/Thread;->start()V

    .line 255
    return-void
.end method

.method private installApk()V
    .locals 6

    .prologue
    .line 261
    new-instance v0, Ljava/io/File;

    const-string v3, "/sdcard/updatedemo/UpdateDemoRelease.apk"

    invoke-direct {v0, v3}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    .line 262
    .local v0, "apkfile":Ljava/io/File;
    invoke-virtual {v0}, Ljava/io/File;->exists()Z

    move-result v3

    if-nez v3, :cond_0

    .line 271
    :goto_0
    return-void

    .line 265
    :cond_0
    iget-object v3, p0, LPlugclass/updateManager;->mContext:Landroid/content/Context;

    const-string v4, "Appset"

    const/4 v5, 0x0

    invoke-virtual {v3, v4, v5}, Landroid/content/Context;->getSharedPreferences(Ljava/lang/String;I)Landroid/content/SharedPreferences;

    move-result-object v2

    .line 266
    .local v2, "userInfo":Landroid/content/SharedPreferences;
    invoke-interface {v2}, Landroid/content/SharedPreferences;->edit()Landroid/content/SharedPreferences$Editor;

    move-result-object v3

    const-string v4, "appdataver"

    const-string v5, "0"

    invoke-interface {v3, v4, v5}, Landroid/content/SharedPreferences$Editor;->putString(Ljava/lang/String;Ljava/lang/String;)Landroid/content/SharedPreferences$Editor;

    move-result-object v3

    invoke-interface {v3}, Landroid/content/SharedPreferences$Editor;->commit()Z

    .line 267
    new-instance v1, Landroid/content/Intent;

    const-string v3, "android.intent.action.VIEW"

    invoke-direct {v1, v3}, Landroid/content/Intent;-><init>(Ljava/lang/String;)V

    .line 268
    .local v1, "i":Landroid/content/Intent;
    new-instance v3, Ljava/lang/StringBuilder;

    const-string v4, "file://"

    invoke-direct {v3, v4}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {v0}, Ljava/io/File;->toString()Ljava/lang/String;

    move-result-object v4

    invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v3

    invoke-static {v3}, Landroid/net/Uri;->parse(Ljava/lang/String;)Landroid/net/Uri;

    move-result-object v3

    const-string v4, "application/vnd.android.package-archive"

    invoke-virtual {v1, v3, v4}, Landroid/content/Intent;->setDataAndType(Landroid/net/Uri;Ljava/lang/String;)Landroid/content/Intent;

    .line 269
    iget-object v3, p0, LPlugclass/updateManager;->mContext:Landroid/content/Context;

    invoke-virtual {v3, v1}, Landroid/content/Context;->startActivity(Landroid/content/Intent;)V

    goto :goto_0
.end method

.method private showDownloadDialog()V
    .locals 5

    .prologue
    .line 179
    new-instance v0, Landroid/app/AlertDialog$Builder;

    iget-object v3, p0, LPlugclass/updateManager;->mContext:Landroid/content/Context;

    invoke-direct {v0, v3}, Landroid/app/AlertDialog$Builder;-><init>(Landroid/content/Context;)V

    .line 180
    .local v0, "builder":Landroid/app/AlertDialog$Builder;
    const-string v3, "\u8f6f\u4ef6\u7248\u672c\u66f4\u65b0"

    invoke-virtual {v0, v3}, Landroid/app/AlertDialog$Builder;->setTitle(Ljava/lang/CharSequence;)Landroid/app/AlertDialog$Builder;

    .line 182
    iget-object v3, p0, LPlugclass/updateManager;->mContext:Landroid/content/Context;

    invoke-static {v3}, Landroid/view/LayoutInflater;->from(Landroid/content/Context;)Landroid/view/LayoutInflater;

    move-result-object v1

    .line 183
    .local v1, "inflater":Landroid/view/LayoutInflater;
    const v3, 0x7f0300b9

    const/4 v4, 0x0

    invoke-virtual {v1, v3, v4}, Landroid/view/LayoutInflater;->inflate(ILandroid/view/ViewGroup;)Landroid/view/View;

    move-result-object v2

    .line 184
    .local v2, "v":Landroid/view/View;
    const v3, 0x7f0c036c

    invoke-virtual {v2, v3}, Landroid/view/View;->findViewById(I)Landroid/view/View;

    move-result-object v3

    check-cast v3, Landroid/widget/ProgressBar;

    iput-object v3, p0, LPlugclass/updateManager;->mProgress:Landroid/widget/ProgressBar;

    .line 186
    invoke-virtual {v0, v2}, Landroid/app/AlertDialog$Builder;->setView(Landroid/view/View;)Landroid/app/AlertDialog$Builder;

    .line 187
    const-string v3, "\u53d6\u6d88"

    new-instance v4, LPlugclass/updateManager$6;

    invoke-direct {v4, p0}, LPlugclass/updateManager$6;-><init>(LPlugclass/updateManager;)V

    invoke-virtual {v0, v3, v4}, Landroid/app/AlertDialog$Builder;->setNegativeButton(Ljava/lang/CharSequence;Landroid/content/DialogInterface$OnClickListener;)Landroid/app/AlertDialog$Builder;

    .line 194
    invoke-virtual {v0}, Landroid/app/AlertDialog$Builder;->create()Landroid/app/AlertDialog;

    move-result-object v3

    iput-object v3, p0, LPlugclass/updateManager;->downloadDialog:Landroid/app/Dialog;

    .line 195
    iget-object v3, p0, LPlugclass/updateManager;->downloadDialog:Landroid/app/Dialog;

    invoke-virtual {v3}, Landroid/app/Dialog;->show()V

    .line 197
    invoke-direct {p0}, LPlugclass/updateManager;->downloadApk()V

    .line 198
    return-void
.end method

.method private showNoticeDialog()V
    .locals 3

    .prologue
    .line 158
    new-instance v0, Landroid/app/AlertDialog$Builder;

    iget-object v1, p0, LPlugclass/updateManager;->mContext:Landroid/content/Context;

    invoke-direct {v0, v1}, Landroid/app/AlertDialog$Builder;-><init>(Landroid/content/Context;)V

    .line 159
    .local v0, "builder":Landroid/app/AlertDialog$Builder;
    const-string v1, "\u8f6f\u4ef6\u7248\u672c\u66f4\u65b0"

    invoke-virtual {v0, v1}, Landroid/app/AlertDialog$Builder;->setTitle(Ljava/lang/CharSequence;)Landroid/app/AlertDialog$Builder;

    .line 160
    iget-object v1, p0, LPlugclass/updateManager;->updateMsg:Ljava/lang/String;

    invoke-virtual {v0, v1}, Landroid/app/AlertDialog$Builder;->setMessage(Ljava/lang/CharSequence;)Landroid/app/AlertDialog$Builder;

    .line 161
    const-string v1, "\u4e0b\u8f7d"

    new-instance v2, LPlugclass/updateManager$4;

    invoke-direct {v2, p0}, LPlugclass/updateManager$4;-><init>(LPlugclass/updateManager;)V

    invoke-virtual {v0, v1, v2}, Landroid/app/AlertDialog$Builder;->setPositiveButton(Ljava/lang/CharSequence;Landroid/content/DialogInterface$OnClickListener;)Landroid/app/AlertDialog$Builder;

    .line 168
    const-string v1, "\u4ee5\u540e\u518d\u8bf4"

    new-instance v2, LPlugclass/updateManager$5;

    invoke-direct {v2, p0}, LPlugclass/updateManager$5;-><init>(LPlugclass/updateManager;)V

    invoke-virtual {v0, v1, v2}, Landroid/app/AlertDialog$Builder;->setNegativeButton(Ljava/lang/CharSequence;Landroid/content/DialogInterface$OnClickListener;)Landroid/app/AlertDialog$Builder;

    .line 174
    invoke-virtual {v0}, Landroid/app/AlertDialog$Builder;->create()Landroid/app/AlertDialog;

    move-result-object v1

    iput-object v1, p0, LPlugclass/updateManager;->noticeDialog:Landroid/app/Dialog;

    .line 175
    iget-object v1, p0, LPlugclass/updateManager;->noticeDialog:Landroid/app/Dialog;

    invoke-virtual {v1}, Landroid/app/Dialog;->show()V

    .line 176
    return-void
.end method


# virtual methods
.method public checkUpdateInfo()V
    .locals 0

    .prologue
    .line 102
    invoke-virtual {p0}, LPlugclass/updateManager;->downupdate()Z

    .line 104
    return-void
.end method

.method public downupdate()Z
    .locals 1

    .prologue
    .line 108
    new-instance v0, LPlugclass/updateManager$3;

    invoke-direct {v0, p0}, LPlugclass/updateManager$3;-><init>(LPlugclass/updateManager;)V

    .line 153
    invoke-virtual {v0}, LPlugclass/updateManager$3;->start()V

    .line 154
    const/4 v0, 0x0

    return v0
.end method
